//
//  UILabel+String.m
//  Shuaiche
//
//  Created by liyanan on 2019/11/13.
//  Copyright © 2019 ShuaiChe. All rights reserved.
//

#import "UILabel+String.h"

@implementation UILabel(String)

- (void)setText:(NSString *)text lineSpacing:(CGFloat)spacing {
    if (!text.length) {
        return;
    }
    NSMutableParagraphStyle *paragraph = [[NSMutableParagraphStyle alloc] init];
    paragraph.lineSpacing = spacing;
    paragraph.lineBreakMode = self.lineBreakMode;
    paragraph.alignment = self.textAlignment;
    NSMutableAttributedString *attributeStr = [[NSMutableAttributedString alloc] initWithString:text];
    [attributeStr addAttributes:@{NSParagraphStyleAttributeName: paragraph} range:NSMakeRange(0, text.length)];
    self.attributedText = attributeStr;
}

@end
